#pragma once
#include "engine/lua-engine.h"
#include "utils.h"

struct LuaWorker : public WorkItemBase {
  void set_script(const std::string &script);

  // --- Constructors ---
  LuaWorker(const std::string &file_path, const std::string &file_root_path,
            const std::shared_ptr<Game> game, const std::shared_ptr<Api> api);
  LuaWorker() = delete;
  LuaWorker(LuaWorker &&) = default;
  LuaWorker(const LuaWorker &) = default;
  LuaWorker &operator=(LuaWorker &&) = default;
  LuaWorker &operator=(const LuaWorker &) = default;
  ~LuaWorker();

private:
  void work(void *context) override;
  void abort() override;

private:
  std::string file_path_;
  std::string file_root_path_;
  std::string script_;
  std::shared_ptr<LuaEngine> engine_;
  std::shared_ptr<LuaApi> api_;
};
